# encoding: utf-8

require 'rubygems'
require 'test/unit'
require File.dirname(__FILE__) + '/../../../lib/capevaluation'
require File.dirname(__FILE__) + '/../../../lib/capevaluation/business/example'
require File.dirname(__FILE__) + '/../../../lib/capevaluation/business/prediction'
require File.dirname(__FILE__) + '/../../../lib/capevaluation/business/crontab'



class Test_Example < Test::Unit::TestCase

  include Capevaluation::Business::Example
  include Capevaluation::Business::Prediction
  include Capevaluation::Business::Crontab




  def setup
    @config = CaiQiu::Support::Config::get_json(File.dirname(__FILE__) + '/../../../etc/ws.json')
    CaiQiu::Core::Launch::load_config(@config)
    @logger = CaiQiu::Support::Log::instance(@config['ws']['log'])
    @redis  = CaiQiu::Support::Redis::instance
    CaiQiu::WebService::CaiQiuSinatra.init(@config['ws'], 5678)
  end

  def teardown
  end

  def test_001_sample
    params = {
        :cmd => 'example',
        :foo => 'bar'
    }
    params = JSON.parse(JSON.generate(params))
    resp   = self.send(params['cmd'], params)
    puts resp.inspect
  end


  def test_002_predict_get_scores
    params =
    {
        "cmd":'predict_get_scores',
        "type":'0',
        "player": 'prediction.FBA2017006'
    }
    params = JSON.parse(JSON.generate(params))
    resp   = self.send(params['cmd'], params)
    puts resp.inspect
  end

  def test_003_predict_get_submits
    params =
        {
            "cmd":'predict_get_submits',
            "type":'0',
            "player": 'prediction.FBA2017006'
            #"page": 1,
            #"count": 40
        }
    params = JSON.parse(JSON.generate(params))
    resp   = self.send(params['cmd'], params)
    puts resp.inspect
  end

  def test_004_predict_get_rankings
    params =
        {
            "cmd":"predict_get_rankings",
            "type":2
            #"page": 1,
            #"count": 40
        }
    params = JSON.parse(JSON.generate(params))
    resp   = self.send(params['cmd'], params)
    puts resp.inspect
  end



  def config
    @config
  end

  def logger
    @logger
  end

  def redis
    @redis
  end
end